import java.sql.*;
public class cr {
    public static void main(String[] args) throws Exception {
        Connection conn = getConn();
        Statement state = conn.createStatement();   //容器
        String sql = "insert into hh values('ling','男','12')";   //SQL语句
        state.executeUpdate(sql);         //将sql语句上传至数据库执行
        System.out.println("一行受到影响");
        conn.close();//关闭通道
    }
    private  static Connection getConn() {
        String driver = "com.mysql.cj.jdbc.Driver";
        String url = "jdbc:mysql://lacalhost:3306/test";
        String username = "root";
        String password = "722821";
        Connection conn = null;
        try{
            Class.forName(driver);
            System.out.println("ghaguyyaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
            conn = DriverManager.getConnection(url, username, password);
            System.out.println("hellohjhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
        }catch (ClassNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return  conn;
    }
}